/**
 * Created with JetBrains WebStorm.
 * User: renji
 * Date: 29/4/13
 * Time: 10:18 AM
 * To change this template use File | Settings | File Templates.
 */

describe("moveToPayeeDetailListController unit test for Indonesia", function() {
    var moveToPayeeDetailListController = null;
    var objE = {errorCode:'code', errorMessage:'message'};
    var transfer = null;
    beforeEach(function() {
        var t_alertCtrl = App.AlertController.create();
        var t_loadingCtrl = App.LoadingController.create();
        transfer = App.OneTimeBillPayment.create();
        var t_moveHolderCtrl = App.MoveHolderController.create();

        App.MoveToPayeeDetailListController.reopen({
            init:function(){
                this.set('controllers.alert', t_alertCtrl);
                this.set('controllers.loading', t_loadingCtrl);
                this.set('controllers.moveHolder', t_moveHolderCtrl);
                this.set('transfer', transfer);
            }
        });
        spyOn(App.getSession(),'getCurrentTransfer').andReturn(transfer);
        moveToPayeeDetailListController = App.MoveToPayeeDetailListController.create();
    });

    it("prepareController", function(){
        spyOn(moveToPayeeDetailListController.get('controllers').get('moveHolder'), 'prepareController');
        moveToPayeeDetailListController.prepareController();
        expect(moveToPayeeDetailListController.get('controllers').get('moveHolder').prepareController).toHaveBeenCalled();
    });

    it("continueAction OneTimeTopUpPayment", function(){

        var t_product  =
                {
                    "field": "Mobile Number",
                    "type": "NUMERIC",
                    "required": true,
                    "value": "",
                    "lengthMax": 30
                };

        var tempTransfer = App.OneTimeTopUpPayment.create({
            biller: App.BillPaymentPayee.create({
                billerValidations:[App.BillerValidation.create(t_product),App.BillerValidation.create(t_product),App.BillerValidation.create(t_product)]
            })
        });

        moveToPayeeDetailListController.set('transfer', tempTransfer);

        spyOn(moveToPayeeDetailListController, 'transitionTo');
        moveToPayeeDetailListController.continueAction();
        expect(moveToPayeeDetailListController.transitionTo).not.toHaveBeenCalledWith("move.fromList");
    });

    it("continueAction OneTimeTopUpPayment", function(){

        var t_product  =
        {
            "field": "Mobile Number",
            "type": "NUMERIC",
            "required": true,
            "value": "12341243124",
            "lengthMax": 30
        };

        var tempTransfer = App.OneTimeTopUpPayment.create({
            biller: App.BillPaymentPayee.create({
                billerValidations:[App.BillerValidation.create(t_product),App.BillerValidation.create(t_product),App.BillerValidation.create(t_product)]
            })
        });

        moveToPayeeDetailListController.set('transfer', tempTransfer);

        spyOn(moveToPayeeDetailListController, 'transitionTo');
        moveToPayeeDetailListController.continueAction();
        expect(moveToPayeeDetailListController.transitionTo).toHaveBeenCalledWith("move.fromList");
    });
    it("continueAction TopUpPayment", function(){

        var t_product  =
        {
            "field": "Mobile Number",
            "type": "NUMERIC",
            "required": true,
            "value": "",
            "lengthMax": 30
        };

        var tempTransfer = App.OneTimeTopUpPayment.create({
            biller: App.BillPaymentPayee.create({
                billerValidations:[App.BillerValidation.create(t_product),App.BillerValidation.create(t_product),App.BillerValidation.create(t_product)]
            })
        });

        moveToPayeeDetailListController.set('transfer', tempTransfer);

        spyOn(moveToPayeeDetailListController, 'transitionTo');
        moveToPayeeDetailListController.continueAction();
        expect(moveToPayeeDetailListController.transitionTo).not.toHaveBeenCalledWith("move.fromList");
    });

    it("continueAction TopUpPayment", function(){

        var t_product  =
        {
            "field": "Mobile Number",
            "type": "NUMERIC",
            "required": true,
            "value": "12341243124",
            "lengthMax": 30
        };

        var tempTransfer = App.OneTimeTopUpPayment.create({
            biller: App.BillPaymentPayee.create({
                billerValidations:[App.BillerValidation.create(t_product),App.BillerValidation.create(t_product),App.BillerValidation.create(t_product)]
            })
        });

        moveToPayeeDetailListController.set('transfer', tempTransfer);

        spyOn(moveToPayeeDetailListController, 'transitionTo');
        moveToPayeeDetailListController.continueAction();
        expect(moveToPayeeDetailListController.transitionTo).toHaveBeenCalledWith("move.fromList");
    });
    it("continueAction", function(){

        var tempTransfer = App.OwnAccountTransfer.create();

        moveToPayeeDetailListController.set('transfer', tempTransfer);

        spyOn(moveToPayeeDetailListController, 'transitionTo');
        moveToPayeeDetailListController.continueAction();
        expect(moveToPayeeDetailListController.transitionTo).toHaveBeenCalledWith("move.fromList");
    });
});